<?php
$this->breadcrumbs=array(
	'Coffee Shops'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List CoffeeShop', 'url'=>array('index')),
	array('label'=>'Create CoffeeShop', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('coffeeshop-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Coffee Shops</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<div class="wide form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
)); 
$yesNoOption=DataUtil::option_yes_no_empty();

?>


	<div class="row">
		<?php echo $form->label($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>64)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'street'); ?>
		<?php echo $form->textField($model,'street',array('size'=>60,'maxlength'=>255)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'suburb'); ?>
		<?php echo $form->textField($model,'suburb',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'state'); ?>
		<?php echo $form->textField($model,'state',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'postcode'); ?>
		<?php echo $form->textField($model,'postcode',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'country'); ?>
		<?php echo $form->textField($model,'country',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'beanRating'); ?>
		<?php echo $form->textField($model,'beanRating',array('size'=>3,'maxlength'=>3)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'baristaNames'); ?>
		<?php echo $form->textField($model,'baristaNames',array('size'=>60,'maxlength'=>128)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'coffeeBrand'); ?>
		<?php echo $form->textField($model,'coffeeBrand',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'espressoMachine'); ?>
		<?php echo $form->textField($model,'espressoMachine',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'beansForSale'); ?>
		<?php echo $form->dropDownList($model,'beansForSale',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'internetAccess'); ?>
		<?php echo $form->dropDownList($model,'internetAccess',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'roastingOnSite'); ?>
		<?php echo $form->dropDownList($model,'roastingOnSite',$yesNoOption); ?>
	</div>

	<!--<div class="row">
		<?php //echo $form->label($model,'status'); ?>
		<?php //echo $form->textField($model,'status'); ?>
	</div>

	-->
	<div class="row">
		<?php echo $form->label($model,'showWeb'); ?>
		<?php echo $form->dropDownList($model,'showWeb',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'showIphone'); ?>
		<?php echo $form->dropDownList($model,'showIphone',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'hotshot'); ?>
		<?php echo $form->dropDownList($model,'hotshot',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'hotChocolate'); ?>
		<?php echo $form->dropDownList($model,'hotChocolate',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'top100'); ?>
		<?php echo $form->dropDownList($model,'top100',$yesNoOption); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'upgraded'); ?>
		<?php echo $form->dropDownList($model,'upgraded',$yesNoOption); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton('Search'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search-form -->
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'coffeeshop-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		//'id',
		array(
			'name' => 'name',
			'type'=>'raw',
			'value' => 'CHtml::link(CHtml::encode($data->name),array("coffeeShop/view","id"=>$data->id))',
		),
		//'street',
		'suburb',
		//'state',
		//'postcode',
		/*
		'country',
		'beanRating',
		'latitude',
		'longitude',
		'review',
		'phone',
		'website',
		'email',
		'ownerName',
		'ownerId',
		'baristaNames',
		'coffeeBrand',
		'espressoMachine',
		'beansForSale',
		'internetAccess',
		'roastingOnSite',
		'volume',
		'timeUpdated',
		'day1Start',
		'day1End',
		'day2Start',
		'day2End',
		'day3Start',
		'day3End',
		'day4Start',
		'day4End',
		'day5Start',
		'day5End',
		'day6Start',
		'day6End',
		'day7Start',
		'day7End',
		'status',
		'showWeb',
		'showIphone',
		'hotshot',
		'hotChocolate',
		'top100',
		'upgraded',
		*/
		array(
			'name' => 'showWeb',
			'type'=>'boolean',
			'filter'=>DataUtil::option_yes_no(),
			),
		array(
			'name' => 'showIphone',
			'type'=>'boolean',
			'filter'=>DataUtil::option_yes_no(),
			),
		array(
			'name' => 'hotshot',
			'type'=>'boolean',
			'filter'=>DataUtil::option_yes_no(),
			),
			array(
			'name' => 'top100',
			'type'=>'boolean',
			'filter'=>DataUtil::option_yes_no(),
			),
			array(
			'name' => 'upgraded',
			'type'=>'boolean',
			'filter'=>DataUtil::option_yes_no(),
			),
			array(
			'name' => 'voteAll',
			'header'=>'Total Vote',
			'filter'=>false,
			),
		array(
			'class'=>'CLinkColumn',
			'header'=>'Images',
 			'labelExpression'=>'$data->imagesCount',
			'urlExpression' => 'array("manageImages","id"=>$data->id)',
		),
//		array(
//			'name' => 'images',
//			'type'=>'raw',
//			'value' => 'count($data->images)',
//		),
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>
